package http_proxy_middleware

import (
	"gin-gateway/middleware"
	"gin-gateway/core/dao"
	"github.com/gin-gonic/gin"
	"errors"
)

func GetServiceDetail(c *gin.Context) *dao.ServiceDetail {
	serverInterface, ok := c.Get("service")
	if !ok {
		middleware.ResponseError(c, 2001, errors.New("service not found"))
		c.Abort()
		return nil
	}
	return serverInterface.(*dao.ServiceDetail)
}

// 租户信息
func GetApp(c *gin.Context) *dao.App {
	appInterface, ok := c.Get("app")
	if !ok {
		middleware.ResponseError(c, 2001, errors.New("app not found"))
		c.Next()
		return nil
	}
	return appInterface.(*dao.App)
}
